home *** CD-ROM | disk | FTP | other *** search
- Path: lowell.bellcore.com!usenet
- From: Rick Porter <fdpo@thumper.bellcore.com>
- Newsgroups: comp.lang.c++
- Subject: nested templates
- Date: 23 Feb 1996 16:46:48 GMT
- Organization: Bell Communications Research (Bellcore)
- Message-ID: <4gkr1o$bg6@lowell.bellcore.com>
- NNTP-Posting-Host: bambam.bellcore.com
-
- I am having trouble using nested templates. Can anyone tell me how to
- make this work, or suggest a workaround? I've reduced the problem to
- the following simple example.
-
- -----------------------------------------------------
- file a.h:
-
- #ifndef A_H
- #define A_H
-
- template<class T>
- class B {
- T b;
- };
-
- template<class T>
- class C {
- T c;
- };
-
- template<class T>
- class A {
- typedef int Atype;
- typedef B<Atype> Btype;
-
- C<Btype> c;
- };
-
-
- #endif
-
- --------------------------------
- file a.C:
-
- #include "a.h"
-
- A<int> a;
-
- ---------------------------------------
- The compiler (HP or Sun) complains:
-
- CC: "t3.h", line 11: error: template class B not yet instantiated;
- please add an explicit instantiation ( typedef B< types>)
-
- g++ works OK.
-
- Thanks,
-
- Rick
-
- BTW, Please don't tell me to get rid of the Atype typedef and replace
- Atype with int. I know that works(!). This is just an example to
- demonstrate the problem.
-
-